﻿<UserControl
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:ui="clr-namespace:Babe.Lua.ToolWindows"
             xmlns:ToolWindows="clr-namespace:Microsoft.LuaTools.ToolWindows" x:Class="Babe.Lua.ToolWindows.SearchToolControl"
             Background="{DynamicResource {x:Static ui:Controls.BackgroundKey}}"
             Foreground="{DynamicResource {x:Static ui:Controls.ForegroundKey}}"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300"
             x:Name="MyToolWindow">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="ResourceDic.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <ToolWindows:BoolVisibilityConventer x:Key="BoolVisibilityConventer"/>
            <DataTemplate x:Key="ListItemTemplate">
                <TextBlock Background="{Binding Background}"><InlineUIContainer>
            			<TextBlock Text="{Binding Id}" Background="Transparent"/>
            		</InlineUIContainer><Run Text=" "/><InlineUIContainer>
            			<TextBlock Text="{Binding PathBase}" Background="Transparent" Visibility="{Binding IsChecked, Converter={StaticResource BoolVisibilityConventer}, ElementName=Button_RelativePath}"/>
            		</InlineUIContainer><Run Text=" "/><InlineUIContainer>
            			<TextBlock Text="{Binding Left}" Background="Transparent"/>
            		</InlineUIContainer><Run Text=" "/><InlineUIContainer>
            			<TextBlock Text="{Binding Highlight}" Background="Tomato" Foreground="Black" Margin="-3,0"/>
            		</InlineUIContainer><Run Text=" "/><InlineUIContainer>
            			<TextBlock Text="{Binding Right}" Background="Transparent"/>
            		</InlineUIContainer></TextBlock>
            </DataTemplate>
            <Style x:Key="ListViewItemStyle1" TargetType="{x:Type ListViewItem}">
                <Setter Property="Background" Value="Transparent"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ListViewItem}">
                            <Border x:Name="Border" BorderBrush="Red" BorderThickness="0" Background="{TemplateBinding Background}">
                                <ContentPresenter x:Name="Content" Content="{TemplateBinding Content}" ContentTemplate="{DynamicResource ListItemTemplate}"/>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsSelected" Value="true">
                                    <Setter Property="Background" TargetName="Border" Value="{DynamicResource {x:Static ui:Controls.ControlBorderPressedKey}}"/>
                                </Trigger>
                                <Trigger Property="IsMouseOver" Value="true">
                                    <Setter Property="Background" TargetName="Border" Value="{DynamicResource {x:Static ui:Controls.ControlBackgroundHoverKey}}"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <ListView x:Name="ListView" Grid.Row="1" Background="Transparent" Foreground="{DynamicResource {x:Static ui:Controls.ForegroundKey}}" 
			MouseDoubleClick="ListView_MouseDoubleClick"
			FontSize="12" BorderBrush="{x:Null}"
			SelectionMode="Single" ItemContainerStyle="{DynamicResource ListViewItemStyle1}"
			SelectionChanged="ListView_SelectionChanged" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
                  />
        <StackPanel Grid.Row="0" Orientation="Horizontal" Visibility="Visible">
            <Button Width="20" Background="{x:Null}" BorderBrush="{x:Null}" ToolTip="copy all results" Margin="2,0" Click="Button_CopyAllResult_Click">
                <Image Source="/BabeLua;component/Resources/copy.png"/>
            </Button>
            <ToggleButton x:Name="Button_RelativePath" Width="20" Background="{x:Null}" BorderBrush="{x:Null}" ToolTip="show relative path" Margin="2,0" Click="Button_RelativePath_Click">
                <Image Source="/BabeLua;component/Resources/relative.png"/>
            </ToggleButton>
            <Button Width="20" Background="{x:Null}" BorderBrush="{x:Null}" ToolTip="clear search results" Margin="2,0" Click="Button_ClearResult_Click">
                <Image Source="/BabeLua;component/Resources/delete.png"/>
            </Button>
            <Line Fill="#FF7E7E7E" Y1="4" Y2="16" Width="2" Margin="4,0" Stroke="#FFBDBCBC"/>
            <TextBox x:Name="TextBox_SearchWord" MinWidth="100" MaxWidth="200" KeyDown="TextBox_SearchWord_KeyDown" Margin="2"/>
            <Button Width="20" Background="{x:Null}" BorderBrush="{x:Null}" ToolTip="search in all files" Click="Button_Search_Click">
                <Image Source="/BabeLua;component/Resources/search.png"/>
            </Button>
            <Button Width="20" Background="{x:Null}" BorderBrush="{x:Null}" ToolTip="search select text in all files" Click="Button_SearchSelect_Click">
                <Image Source="/BabeLua;component/Resources/search2.png"/>
            </Button>
        </StackPanel>
    </Grid>
</UserControl>
